import { request } from '@/request/request';
import {Product} from "@/api/product/type";
// @ts-ignore


/**
 * 商城Banner.
 * @param data
 */
export const getMallBanner = (data: any): Promise<any> => {
    return request({ url: '/mall/banner', data, method: 'GET' })
}

/**
 * 商品分类.
 * @param data
 */
export const getCategory = (data: any): Promise<any> => {
    return request({ url: '/mall/product/category', data, method: 'GET' })
}

/**
 * 商品标签.
 * @param data
 */
export const getLabels = (data: any): Promise<any> => {
    return request({ url: '/mall/product/labels', data, method: 'GET' })
}

/**
 * 热卖.
 * @param data
 */
export const getHotSell = (data: any): Promise<any> => {
    return request({ url: '/mall/product/hotSell', data, method: 'GET' })
}

/**
 * 新品.
 * @param data
 */
export const getNewProducts = (data: any): Promise<any> => {
    return request({ url: '/mall/product/newProducts', data, method: 'GET' })
}


/**
 * 商品列表.
 * @param data
 */
export const getProductList = (data: Product.GetProductListParam): Promise<any> => {
    return request({ url: '/mall/product/productList', data, method: 'GET' })
}

/**
 * 商品详情.
 * @param data
 */
export const getProductDetail = (data: any): Promise<any> => {
    return request({ url: '/mall/product/details', data, method: 'GET' })
}

/**
 * 最新评论.
 * @param data
 */
export const getLatestReview = (data: any): Promise<any> => {
    return request({ url: '/mall/product/latestReview', data, method: 'GET' })
}


/**
 * 全部评论.
 * @param data
 */
export const getAllReview = (data: any): Promise<any> => {
    return request({ url: '/mall/product/allReview', data, method: 'GET' })
}

/**
 * 立即购买预览.
 * {
 *    "sku_id": 18,
 *    "quantity": 1
 * }
 * @param data
 */
export const beforeCheckout = (data: any): Promise<any> => {
    return request({ url: '/mall/product/beforeCheckout', data, method: 'POST' })
}

/**
 * 单独下单提交.
 * @param data
 */
export const singleConfirmCheckout = (data: Product.CheckoutParam) => {
    return request({ url: '/mall/product/singleConfirmCheckout', data, method: 'POST' })
}

